#! /bin/bash  
if [ "$7" != "" ] && [ "$8" != "" ] && [ "$9" != "" ];then
    echo "----------------------------------> exec: login docker registry [$7] ..."
    docker login $7 -u $8 -p $9
else  
    echo "----------------------------------> docker registry does not need to log in"
fi

if [ $? -eq 0 ]; then
	echo "----------------------------------> exec: [s2i build -e PROFILE=docker -e WAR_NAME=$1 -e INCREMENTAL=true -e POM_PATH=$2 --incremental $3 $4 $5 -r $6] and [docker push $5] ..."
	s2i build -e PROFILE=docker -e WAR_NAME=$1 -e INCREMENTAL=true -e POM_PATH=$2 --incremental $3 $4 $5 -r $6 && docker push $5
fi

